home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE06 / CLINIC / MANYU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-30  |  1.4 KB  |  68 lines

  1. unit Manyu;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     MainMenu1: TMainMenu;
  12.     Help1: TMenuItem;
  13.     About1: TMenuItem;
  14.     Button1: TButton;
  15.     Button2: TButton;
  16.     Edit1: TEdit;
  17.     procedure Button1Click(Sender: TObject);
  18.     procedure Button2Click(Sender: TObject);
  19.     procedure About1Click(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. uses TypInfo;
  32.  
  33. {$R *.DFM}
  34.  
  35. procedure ActivateControls(SetTo: Boolean;
  36.   const ControlsToChange: array of const);
  37. var
  38.   I: integer;
  39.   PropInfo: PPropInfo;
  40. begin
  41.  for I := Low(ControlsToChange) to High(ControlsToChange) do
  42.    with TVarRec(ControlsToChange[I]) do
  43.      { Sanity check to see if it is an object }
  44.      if VType = vtObject then
  45.      begin
  46.        PropInfo := GetPropInfo(VObject.ClassInfo, 'Enabled');
  47.        if Assigned(PropInfo) then
  48.          SetOrdProp(VObject, PropInfo, LongInt(SetTo));
  49.      end;
  50. end;
  51.  
  52. procedure TForm1.Button1Click(Sender: TObject);
  53. begin
  54.   ActivateControls(False, [Button1, Edit1, About1]);
  55. end;
  56.  
  57. procedure TForm1.Button2Click(Sender: TObject);
  58. begin
  59.   ActivateControls(True, [Button1, Edit1, About1]);
  60. end;
  61.  
  62. procedure TForm1.About1Click(Sender: TObject);
  63. begin
  64.   MessageDlg('About Box', mtInformation, [mbOk], 0);
  65. end;
  66.  
  67. end.
  68.